package com.jmag.nop.service.common.verify;

import com.jmag.nop.service.common.util.AESUtil;
import com.jmag.nop.service.common.util.RSANewUtil;
import com.jmag.nop.service.common.util.RSAUtil;
import org.apache.commons.codec.digest.DigestUtils;
/**
 * @ClassName ApiEncrypter
 * @Description TODO
 * @Author JMAG
 * @Version 1.0
 **/
public class ApiEncrypter implements Encrypter {
    public ApiEncrypter() {
    }

    public String aesEncryptToHex(String content, String password) throws Exception {
        return AESUtil.encryptToHex(content, password);
    }

    public String aesDecryptFromHex(String hex, String password) throws Exception {
        return AESUtil.decryptFromHex(hex, password);
    }

    public String aesEncryptToBase64String(String content, String password) throws Exception {
        return AESUtil.encryptToBase64String(content, password);
    }

    public String aesDecryptFromBase64String(String base64String, String password) throws Exception {
        return AESUtil.decryptFromBase64String(base64String, password);
    }

    public String rsaDecryptByPrivateKey(String data, String privateKey) throws Exception {
        return RSAUtil.decryptByPrivateKey(data, privateKey);
    }

    public String rsaEncryptByPrivateKey(String data, String privateKey) throws Exception {
        return RSAUtil.encryptByPrivateKey(data, privateKey);
    }

    public String rsaDecryptByPrivateKeyNew(String data, String privateKey) throws Exception {
        return RSANewUtil.decryptByPrivateKey(data, privateKey);
    }

    public String rsaEncryptByPrivateKeyNew(String data, String privateKey) throws Exception {
        return RSANewUtil.encryptByPrivateKey(data, privateKey);
    }

    public String md5(String value) {
        return DigestUtils.md5Hex(value);
    }
}
